package com.bamboo.statistics.controller;


import com.bamboo.commonutils.ResponseEntity;
import com.bamboo.statistics.service.DailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author jack.wu
 * @since 2020-07-22
 */
@Api("统计管理")
@RestController
@RequestMapping("/statistics/daily")
@CrossOrigin
public class DailyController {

    @Resource
    private DailyService dailyService;

    @ApiOperation("创建统计数据")
    @PostMapping("registerCount/{day}")
    public ResponseEntity createRegisterCount(@PathVariable String day) {
        dailyService.getRegisterCount(day);
        return ResponseEntity.ok();
    }

    @ApiOperation("查询图表显示")
    @GetMapping("showData/{type}/{begin}/{end}")
    public ResponseEntity showData(@PathVariable String type,@PathVariable String begin,
                      @PathVariable String end) {
        Map<String,Object> map = dailyService.getShowData(type,begin,end);
        return ResponseEntity.ok().data(map);
    }

}

